#!/bin/env python
#coding=utf-8
'''
author: monkey
'''
import glob
import os,sys

input_argv = str(sys.argv[2])
files = glob.glob("/opt/fonsview/data/epg/iptvdata/backup/*")
if not os.path.exists('/opt/fonsview/data/epg/iptvdata/backup'):
    exit(0)
files.sort(key=os.path.getmtime)
files.reverse()
epg_file = files[0]

if not os.path.isfile(epg_file):
    exit(0)
with open(epg_file,'r') as file:
    data = file.readlines()
for x in data:
	cc =  x.strip().split('|')
	cc.reverse()
total_count = cc[0]
success_count = cc[1]
request_rate = float(success_count) / float(total_count)


if input_argv == 'success_count':
	print success_count
elif input_argv == 'total_count':
	print total_count
elif input_argv == 'request_rate':
	print request_rate